<template>
  <div id="app">
      <el-container>
          <el-header height="40px">
              <el-menu @select="handleSelect" :default-active="activeIndex" mode="horizontal" background-color="#545c64" text-color="#fff" active-text-color="#ffd04b">
                  <el-menu-item index="1"><a href="/">首页</a></el-menu-item>
                  <el-menu-item index="2"><a href="/order">订单</a></el-menu-item>
                  <el-menu-item index="3"><a href="/center">我的</a></el-menu-item>
              </el-menu>
          </el-header>
          <el-main>
              <router-view/>
          </el-main>
      </el-container>
  </div>
</template>

<script>

export default {
    name: 'app',
    data() {
      return {
          // 当前导航
          activeIndex: sessionStorage.getItem("activeIndex") == null ? "1" : sessionStorage.getItem("activeIndex"),
      }
    },
    methods: {
        // 导航栏切换事件
        handleSelect(index) {
            sessionStorage.setItem("activeIndex", index);
        }
    }
}
</script>

<style scoped>
    a {
        text-decoration: none;
    }
</style>
